<?php

class Ialbum_Widget_AlbumsOfUsersController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
  	$this->getElement()->removeDecorator('Title');
    // Don't render this if not authorized
    $viewer = Engine_Api::_()->user()->getViewer();
    if( !Engine_Api::_()->core()->hasSubject() ) {
      return $this->setNoRender();
    }
    
    $front_controller = Zend_Controller_Front::getInstance ();
    $type = $front_controller->getRequest()->getParam('type', '');   
 	$subject = $front_controller->getRequest()->getParam('subject', '');
 	if($type == 'viewall' && $subject == 'albums'){
 		return $this->setNoRender();
 	}
	$subject =  Engine_Api::_()->core()->getSubject();
    // Get paginator
    $this->view->paginator = $paginator = Engine_Api::_()->getItemTable('album')
      ->getAlbumPaginator(array('owner' => $subject, 'search' => 1));

    // Set item count per page and current page number
    $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', $this->_getParam('itemCountPerPage', 8)));
    $paginator->setCurrentPageNumber($this->_getParam('page', 1));

    // Do not render if nothing to show
//    if( $paginator->getTotalItemCount() <= 0 ) {
//      return $this->setNoRender();
//    }

  }
}